package sz.szsmk.citizencard.ui.newversion.activity

import android.os.Bundle
import androidx.navigation.NavDestination
import androidx.navigation.NavGraph
import androidx.navigation.Navigation
import androidx.navigation.fragment.NavHostFragment
import com.chenenyu.router.annotation.Route
import com.gyf.immersionbar.ImmersionBar
import com.gyf.immersionbar.ktx.immersionBar
import kotlinx.android.synthetic.main.activity_logoff.*
import sz.szsmk.citizencard.R
import sz.szsmk.citizencard.ui.dzsmkavtivity.AppBaseActivity
import sz.szsmk.citizencard.ui.newversion.config.Constants
import sz.szsmk.citizencard.ui.newversion.fragment.HomeFragment
import sz.szsmk.citizencard.ui.newversion.fragment.LogoffSecondPageFragment

/**
 *  author : hyt
 *  date : 2020/8/12
 *  description :
 */
@Route(Constants.LOGOFF)
class LogoffActivity : AppBaseActivity() {

    override fun getTopTitle() =  null
    override fun initSystemBar() {
        immersionBar{
            reset()
            fitsSystemWindows(true)  //使用该属性,必须指定状态栏颜色
            statusBarDarkFont(true)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_logoff)

        back.setOnClickListener {
            var navHostFragment: NavHostFragment = supportFragmentManager.findFragmentById(R.id.nav_logoff_fragment) as NavHostFragment
            if(navHostFragment.childFragmentManager.fragments.get(0) is LogoffSecondPageFragment){
                Navigation.findNavController(this, R.id.nav_logoff_fragment).navigateUp()
            }else{
                finish()
            }

        }

        var navHostFragment: NavHostFragment = supportFragmentManager.findFragmentById(R.id.nav_logoff_fragment) as NavHostFragment
        var navSimple: NavGraph = navHostFragment.navController.navInflater.inflate(R.navigation.app_navigation)

        navSimple.startDestination = R.id.fragment_logofffirstpage
        navHostFragment.navController.graph = navSimple

    }
}